package com.chucang.shucang.ttp.messagecenter.factory;

import com.chucang.shucang.ttp.messagecenter.enums.STRATEGY_TYPE;
import com.chucang.shucang.ttp.messagecenter.strategy.MessageStrategy;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2022/9/26 17:40
 * @description 消息工厂
 */
@Slf4j
public class MessageFactory {

    public static MessageStrategy getMessageStrategy(STRATEGY_TYPE strategyType) {
        MessageStrategy messageStrategy = null;
        try {
            messageStrategy = (MessageStrategy) Class.forName(strategyType.getStrategyType()).getDeclaredConstructor().newInstance();
        } catch (Exception e) {
            log.error("生成策略失败！！");
        }
        return messageStrategy;
    }

}
